<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<p>整数1：<input type="text" id="num1"></p>
	<p>整数2：<input type="text" id="num2"></p>
	<button onclick="operation('+')">相加</button>
	<button onclick="operation('-')">相减</button>
	<button onclick="operation('*')">相乘</button>
	<button onclick="operation('/')">相除</button>
	<p>结果：<input type="text" id="result"></p>
	<script>
		function operation(a){
			var num1 = document.querySelector('#num1').value;
			var num2 = document.querySelector('#num2').value;
			num1 = Number(num1);
			num2 = Number(num2);
			var result = 0;
			switch(a){
				case '+':result = num1+num2;break;
				case '-':result = num1-num2;break;
				case '*':result = num1*num2;break;
				case '/':result = num1/num2;break;
			}
			document.querySelector('#result').value = result;

		}
	</script>
</body>
</html>